<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="../js/vue.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div id="root">
			<button @click="update">更新</button>
			<ul>
				<li v-for="(p,index) in persons" :key="p.id">
					{{p.id}}-{{p.name}}-{{p.age}}-{{p.sex}}
				</li>
			</ul>

		</div>
		<script type="text/javascript">
			// 用computed实现
			const vm = new Vue({
				el: '#root',
				data: {
					keyWord: '',
					sortType: 0,
					persons: [{
							id: '001',
							name: '马冬梅',
							age: 30,
							sex: '女'
						},
						{
							id: '002',
							name: '周冬雨',
							age: 26,
							sex: '女'
						},
						{
							id: '003',
							name: '周杰伦',
							age: 20,
							sex: '男'
						},
						{
							id: '004',
							name: '温兆伦',
							age: 44,
							sex: '男'
						}
					]
				},
				methods: {
					update() {
						// this.persons[0].name='马牛逼'   有效
						this.persons[0] = {
							id: '001',
							name: '马牛逼',
							age: 30,
							sex: '男'
						}
					}
				}
			})
		</script>
	</body>
</html>
